<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Employee extends Model
{
    
    protected $table = 'employee';
    protected $primaryKey = 'employee_id';
    public $incrementing = true;
    protected $hidden = [];
    protected $guarded = [];

//    protected $fillable = ['edid','eid','CurrentHumidity','CurrentTemperature','LightLux','SoilMoisture','SoilTemperature','soilEC','Time','RequestId','greenhouseName','cropName','ctime', 'mtime','dtime','gid'];
    public $timestamps = false;
    public static function getList($where)
    {

        $data = DB::table('employee as e')
            ->orderBy('e.employee_id','desc');


        if(!empty($where['name']))
        {
            $data->where('e.name','like','%'.$where['name'].'%');
        }

        if(!empty($where['mobile']))
        {
            $data->where('e.mobile',$where['mobile']);
        }
        if(!empty($where['status']))
        {
            $data->where('e.status',$where['status']);
        }
        if(!empty($where['company_id']))
        {
            $data->where('e.company_id',$where['company_id']);
        }

        if (!empty($where['employee_status']))
        {
            $data->where('e.employee_status',$where['employee_status']);
        }
        if (!empty($where['work_nature']))
        {
            $data->where('e.work_nature',$where['work_nature']);
        }
        return $data->paginate(20);
    }


}